# coding:utf-8
"""
Author: 11203
Date:  17:03
Name: __init__.py
"""
from flask import Blueprint
from flask_restful import Api

from common.utils.response_utils import output_json
from shopping.resources.user.user_resources import UserResource, AuthorizationResource, RegisterUserResource, \
    LoginUserResource, TestRequest

# 用户蓝图资源
users_bp = Blueprint('users', __name__)
# 创建蓝图中的资源Api
user_api = Api(users_bp)

# 替代: @user_api.representation('application/json')的写法
user_api.representation('application/json')(output_json)

# 添加用户的资源类
user_api.add_resource(UserResource, '/account', endpoint='account')
user_api.add_resource(LoginUserResource, '/account_login', endpoint='login')
user_api.add_resource(AuthorizationResource, '/accout_auth', endpoint='auth')
user_api.add_resource(RegisterUserResource, '/account_regist', endpoint='regist')

# 请求单元测试
user_api.add_resource(TestRequest, '/test', endpoint='test')